package com.ruoyi.device.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.TFloorMapper;
import com.ruoyi.device.domain.TFloor;
import com.ruoyi.device.service.ITFloorService;

import static com.ruoyi.common.security.utils.SecurityUtils.getLoginUser;

/**
 * 楼层Service业务层处理
 * 
 * @author li
 * @date 2025-09-22
 */
@Service
public class TFloorServiceImpl implements ITFloorService 
{
    @Autowired
    private TFloorMapper tFloorMapper;

    /**
     * 查询楼层
     * 
     * @param id 楼层主键
     * @return 楼层
     */
    @Override
    public TFloor selectTFloorById(Long id)
    {
        return tFloorMapper.selectTFloorById(id);
    }

    /**
     * 查询楼层列表
     * 
     * @param tFloor 楼层
     * @return 楼层
     */
    @DataScope(deptAlias = "d")
    @Override
    public List<TFloor> selectTFloorList(TFloor tFloor)
    {
        return tFloorMapper.selectTFloorList(tFloor);
    }

    /**
     * 新增楼层
     * 
     * @param tFloor 楼层
     * @return 结果
     */
    @Override
    public int insertTFloor(TFloor tFloor)
    {
        tFloor.setCreateBy(getLoginUser().getUsername());
        tFloor.setCreateTime(DateUtils.getNowDate());
        return tFloorMapper.insertTFloor(tFloor);
    }

    /**
     * 修改楼层
     * 
     * @param tFloor 楼层
     * @return 结果
     */
    @Override
    public int updateTFloor(TFloor tFloor)
    {
        tFloor.setUpdateBy(getLoginUser().getUsername());
        tFloor.setUpdateTime(DateUtils.getNowDate());
        return tFloorMapper.updateTFloor(tFloor);
    }

    /**
     * 批量删除楼层
     * 
     * @param ids 需要删除的楼层主键
     * @return 结果
     */
    @Override
    public int deleteTFloorByIds(Long[] ids)
    {
        return tFloorMapper.deleteTFloorByIds(ids);
    }

    /**
     * 删除楼层信息
     * 
     * @param id 楼层主键
     * @return 结果
     */
    @Override
    public int deleteTFloorById(Long id)
    {
        return tFloorMapper.deleteTFloorById(id);
    }
}
